/*
-------------------------------------------------------------------
BIE is Copyright 2001-2004 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------

*/
/*
 * Test.java
 *
 * Created on December 16, 2003, 11:22 AM
 */

package com.webdeninteractive.bie.qa.performance;

import com.webdeninteractive.bie.qa.load.Load;
import java.util.*;
import java.io.*;
import com.webdeninteractive.toolkit.*;

/**
 *
 * @author  jd
 */
public class Reporter {
    
    /** Creates a new instance of Test */
    public Reporter() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        
        
        Properties setup = PropertiesTools.getPropObj(System.getProperty("xbotts.home") + "/conf/reporter.properties");
        
        String fileList = setup.getProperty("message.list");        
        //String fileList = "kb5.csv,kb50.csv,kb100.csv,kb250.csv,kb500.csv,kb750.csv,mb1.csv,mb3.csv,mb5.csv,mb7.csv,mb10.csv,mb15.csv,mb20.csv,mb30.csv";                
        int numConcurrent = Integer.parseInt(setup.getProperty("numConcurrent.start"));
        
        Properties props = new Properties();
                                
        props.put("numRequests",setup.getProperty("numRequests"));
        props.put("numConcurrent",numConcurrent + "");
        props.put("wait","10");
        props.put("repititions","1");
        props.put("services","soap");
        props.put("reportFile",setup.getProperty("report.file"));
        props.put("soap.class","com.webdeninteractive.xbotts.client.serviceproviders.BIEWSClient");
        props.put("soap.message","none");
        props.put("soap.endPointURL",setup.getProperty("endPointURL"));
        props.put("soap.username",setup.getProperty("bie.username"));
        props.put("soap.password",setup.getProperty("bie.password"));
        props.put("soap.destinationRouteID",setup.getProperty("bie.routeID"));
                
        boolean numConcurrentOK = true;
        while (numConcurrentOK) {            
            StringTokenizer st = new StringTokenizer(fileList,",");
            while (st.hasMoreTokens()) {
                props.put("soap.message", System.getProperty("xbotts.home") + File.separator + "docs" + File.separator + st.nextToken());
                
                Load.runLoadTest(props);
                Load.reset();
                System.out.println("about to sleep");
                Thread.sleep(2000);
            }
                        
            numConcurrent =  numConcurrent + Integer.parseInt(setup.getProperty("numConcurrent.increment"));
            if (numConcurrent > Integer.parseInt(setup.getProperty("numRequests")) || numConcurrent > Integer.parseInt(setup.getProperty("numConcurrent.max"))  ) {
                numConcurrentOK = false;
            }else {
                props.put("numConcurrent", numConcurrent + "");
            }
        }
    }
    
/*
        StringTokenizer st = new StringTokenizer(fileList,",");
        while (st.hasMoreTokens()) {
            props.put("soap.message", System.getProperty("xbotts.home") + File.separator + "docs" + File.separator + st.nextToken());
            boolean numConcurrentOK = true;
            props.put("numConcurrent", "1");
            while (numConcurrentOK) {
                Load.runLoadTest(props);
                Load.reset();
 
                int numConcurrent = Integer.parseInt(props.getProperty("numConcurrent"));
 
                numConcurrent =  numConcurrent + numConcurrent;
                if (numConcurrent > Integer.parseInt(setup.getProperty("numRequests"))) {
                    System.out.println("setting num con to false");
                    numConcurrentOK = false;
                }else {
                    props.put("numConcurrent", numConcurrent + "");
                }
            }
        }
 */
}

